package com.app.service;

import com.app.model.main.MeetRecord;
import com.app.repository.interfaces.MeetRecordMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Lichaojie on 2017/5/7. It's a beautiful day.
 */
@Service
public class MeetRecordService {

    @Autowired
    private MeetRecordMapper meetRecordMapper;

    public int getMeetTimesByDay(int days,long userId){
        long time2 = System.currentTimeMillis();
        long time1 = time2 - days * 24 * 60 * 60 * 1000;

        List<MeetRecord> meetRecordList = meetRecordMapper.selectByReceiverIdBetween(userId,Long.toString(time1),Long.toString(time2));

        if(meetRecordList != null){
            return meetRecordList.size();
        }else {
            return 0;
        }

    }
}
